package lvcy.message.sender;

import java.io.IOException;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import lvcy.message.http.HttpClientGenerator;
import lvcy.message.thread.CountableThreadPool;

public class HytMessageSender implements MessageSender{

	private Logger log=LogManager.getLogger(DxtMessageSender.class);
	private String requestUrl;
	private String postData;
	private HytMessageSender(String requestUrl,String postData) {
		this.requestUrl=requestUrl;
		this.postData=postData;
	}
	@Override
	public void run() {
		CloseableHttpClient httpClient=HttpClientGenerator.getInstance().getHttpClient();
		String url=requestUrl+"?"+postData;
		HttpPost httpPost=new HttpPost(url);
		try {
			HttpResponse response=httpClient.execute(httpPost);
			handleResponse(response);
		} catch (IOException e) {
			log.error(e);
		}
	}

	@Override
	public void send() throws InterruptedException{
		CountableThreadPool.INSTANCE.execute(this);
	}
	private void handleResponse(HttpResponse response){

		log.info("// TODO");
	}

}
